package org.example.designpatterns.singleton.demo1;

/**
 * @author Gong.Yang
 * 懒汉式   静态内部类
 * 在Singleton被类加载器加载时，其内部的静态私有类并不会被加载
 */
public class Singleton {
    private Singleton() {
        System.out.println("单例实例化");
    }


    private static class SingletonHHolder {
        private static final Singleton singleton = new Singleton();
    }

    public static Singleton instance() {
        return SingletonHHolder.singleton;
    }
}
